package com.example.apiproject.entity.form;

import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;


@Data
public class AddPostForm implements Serializable {

    private static final long serialVersionUID = 1L;


//    /**
//     * 圈子id
//     */
//    @NotNull(message = "无参数圈子id")
//    private Integer topicId;
//    /**
//     * 话题id
//     */
//    private Integer discussId;

    /**
     * 标题
     */
    @Length(max = 50, message = "标题不能超过20个字符")
    @NotBlank(message = "参数有误")
    private String title;
    /**
     * 内容
     */
    @Length(max = 500, message = "内容不能超过400个字符")
    @NotBlank(message = "参数有误")
    private String content;
    /**
     * 文件
     */
    private List<String> media;


    @NotNull(message = "无参数type")
    private Integer type;
    /**
     * 地址名称
     */
    private String address;


//    /**
//     * 分类id
//     */
//    private Integer cut;
    /**
     * 标签
     */
    private String cateName;

    /**
     * 寻搭活动时间
     */
    private LocalDateTime startTime;
    /**
     * 寻搭规模
     */
    private Integer index;
    public void setStartTime(String startTime) {
        if(startTime!=null){
        DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
        LocalDateTime LocalTime = LocalDateTime.parse(startTime,df);
        this.startTime = LocalTime;}
        else {this.startTime=null;}
    }

    /**
     * 帖子标签
     */
    private String labels;


}
